package com.dlc.demo.daiqianma.presenter;

import com.dlc.demo.daiqianma.entity.ApplyForLoanSubmitStateEntity;
import com.dlc.demo.daiqianma.iview.IApplyForLoanView;
import com.dlc.demo.daiqianma.model.ApplyForLoanModel;
import com.dlc.demo.daiqianma.model.Callback;
import com.dlc.demo.daiqianma.util.SharedPreferencesHelper;

/**
 * 申请业务
 */
public class ApplyForLoanPresenter extends BasePresenter<IApplyForLoanView> {
    /**
     * 获取提交信息状态
     */
    public void getApplyForLoanState(){
        getView().showLoading();
        //从缓存中获取token
        String token = SharedPreferencesHelper.getToken(getView().getContext());
        ApplyForLoanModel.getApplyForLoanState(token, new Callback<ApplyForLoanSubmitStateEntity>() {
            @Override
            public void onSuccess(ApplyForLoanSubmitStateEntity data) {
                getView().showSubmitedInfo(data);
            }

            @Override
            public void onFailure(String msg) {
                getView().showToast(msg);
            }

            @Override
            public void onError() {
                getView().showErr();
            }

            @Override
            public void onComplete() {
                getView().hideLoading();
            }
        });
    }
}
